﻿@page
@{
    ViewData["Title"] = "查看数据表";
    Layout = "~/Pages/Admin/_Layout.cshtml";
}



<div id="container">


        <div class="list-wall">
            <table class="layui-hide" id="tablelist" lay-filter="tblist"></table>
        </div>

        <script>
            layui.use(['jquery', 'common', 'table'],
                function () {
                    $ = layui.jquery,
                        os = layui.common,
                        table = layui.table


                    var tableName = os.getUrlParam('tableName');

                    //加载表格数据
                    os.tableRender({
                        elem: '#tablelist',
                        url: "/api/admin/codegenerator/querytablecolumn?tableName=" + tableName,
                        parseData: function (res) { //res 即为原始返回的数据
                            return {
                                "code": res.code == 1 ? 0 : 1,
                                "msg": res.msg,
                                "data": res.data //解析数据列表
                            };
                        },
                        page: false,
                        cols: [
                            [
                                { field: 'colName', title: '列名', sort: true, fixed: 'left' },
                                { field: 'isPrimaryKey', title: '是否主键' },
                                { field: 'columnType', title: '数据类型' },
                                { field: 'columnLength', title: '列长度' },
                                { field: 'isNullable', title: '允许Null值' },
                                { field: 'defaultValue', title: '默认值' },
                                {field:'comment',title:'说明',width:200}
                            ]
                        ]
                    })

                    var active = {

                        reload: function () {
                            os.tableReload('tablelist',
                                { where: {}, page: false }
                            )
                        },
                        //生成代码
                        CreatCode: function () {

                        },

                    };
                    $('.list-search .layui-btn').on('click', function () {
                        var type = $(this).data('type');
                        active[type] ? active[type].call(this) : '';
                    });

                   

                });
        </script>

</div>